<?php
// Inialize session
session_start ();

// Check, if username session is NOT set then this page will jump to login page
if (! isset ( $_SESSION ['username'] )) {
	header ( 'Location: index.php' );
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Add Data</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script src="calenderPopup.js">
	</script>
<script>
		var cal = new CalendarPopup();
	</script>
	<?php
	include_once 'functions.php';
	include_once 'additionalFunctions.php'?>
</head>

<body>
	<?php
	include 'headinfo.php';
	?>
	<hr />
<div id="header">
		<?php
		$thispage = "Add Crop Data";
		require 'menu.php';
		?>
		<!-- end #menu --></div>
<!-- end #header -->
<!-- end #header-wrapper -->
<div id="page">
<div id="content">
<div class="post">
<h2 class="title"><a href="#">Add Crop Data</a></h2>


<p class="meta"></p>
		  		<?php
						$thissubpage = "Donation";
						require 'menu_addCropData.php';
						?>		
				
    						<form method="post" action="insert_donation_process.php">
<table class="tablecss" width="600" border="1">
	<tr height=50>
		<th colspan="5" scope="row">
		<h2>Donation</h2>
		</th>
	</tr>
	<tr>
		<th colspan="5" scope="row">Date: <input id="date" type="text"
			name="date" size="15"
			value="<?php
			if (isset ( $_GET ['date'] )) {
				echo $_GET ['date'];
			} else {
				date_default_timezone_set ( 'EST' );
				echo date ( "Y-m-d" );
			}
			?>" /> <a href="#" id="anchor1" name="anchor1"
			onclick="cal.select(document.getElementById('date'), 'anchor1', 'yyyy-MM-dd'); return false;">Calendar</a>
		</th>
	</tr>
	<tr>
		<td colspan="2" scope="row" align="center"><select
			name="cropNameWithUnit1" id="cropNameWithUnit1">
        								<?php
																if (isset ( $_GET ['cropNameWithUnit1'] )) {
																	echo "<option value='";
																	echo $_GET ['cropNameWithUnit1'];
																	echo " '>";
																	echo $_GET ['cropNameWithUnit1'];
																	echo "</option>";
																}
																$allCrops = getAllCrops ();
																for($i = 0; $i < count ( $allCrops ); $i ++) {
																	$units = getUnitsByCropname ( $allCrops [$i] ['cropname'] );
																	for($j = 0; $j < count ( $units ); $j ++) {
																		if ($units [$j] != null) {
																			echo "<option value='";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo " '>";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo "</option>";
																		}
																	}
																}
																?>
	              						</select></td>
		<td colspan="2" align="center"><input name="cropNum1"
			value="<?php
			if (isset ( $_GET ['cropNum1'] )) {
				echo $_GET ['cropNum1'];
			} else {
				echo 0;
			}
			?>" /></td>
		<td colspan="1" align="center"><select name="customer1" id="customer1">
            								<?php
																				if (isset ( $_GET ['customer1'] )) {
																					echo "<option value='";
																					echo $_GET ['customer1'];
																					echo " '>";
																					echo $_GET ['customer1'];
																					echo "</option>";
																				}
																				$allCustomers = getDonationCustomers ();
																				for($i = 0; $i < count ( $allCustomers ); $i ++) {
																					echo "<option value=\"" . $allCustomers [$i] ['customername'] . "\">" . $allCustomers [$i] ['customername'] . "</option>";
																				}
																				?>
	              						</select></td>
	</tr>
	<tr>
		<td colspan="2" scope="row" align="center"><select
			name="cropNameWithUnit2" id="cropNameWithUnit2">
        								<?php
																if (isset ( $_GET ['cropNameWithUnit2'] )) {
																	echo "<option value='";
																	echo $_GET ['cropNameWithUnit2'];
																	echo " '>";
																	echo $_GET ['cropNameWithUnit2'];
																	echo "</option>";
																}
																$allCrops = getAllCrops ();
																for($i = 0; $i < count ( $allCrops ); $i ++) {
																	$units = getUnitsByCropname ( $allCrops [$i] ['cropname'] );
																	for($j = 0; $j < count ( $units ); $j ++) {
																		if ($units [$j] != null) {
																			echo "<option value='";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo " '>";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo "</option>";
																		}
																	}
																}
																?>
	              						</select></td>
		<td colspan="2" align="center"><input name="cropNum2"
			value="<?php
			if (isset ( $_GET ['cropNum2'] )) {
				echo $_GET ['cropNum2'];
			} else {
				echo 0;
			}
			?>" /></td>
		<td colspan="1" align="center"><select name="customer2" id="customer2">
            								<?php
																				if (isset ( $_GET ['customer2'] )) {
																					echo "<option value='";
																					echo $_GET ['customer2'];
																					echo " '>";
																					echo $_GET ['customer2'];
																					echo "</option>";
																				}
																				$allCustomers = getDonationCustomers ();
																				for($i = 0; $i < count ( $allCustomers ); $i ++) {
																					echo "<option value=\"" . $allCustomers [$i] ['customername'] . "\">" . $allCustomers [$i] ['customername'] . "</option>";
																				}
																				?>
	              						</select></td>
	</tr>
	<tr>
		<td colspan="2" scope="row" align="center"><select
			name="cropNameWithUnit3" id="cropNameWithUnit3">
        								<?php
																if (isset ( $_GET ['cropNameWithUnit3'] )) {
																	echo "<option value='";
																	echo $_GET ['cropNameWithUnit3'];
																	echo " '>";
																	echo $_GET ['cropNameWithUnit3'];
																	echo "</option>";
																}
																$allCrops = getAllCrops ();
																for($i = 0; $i < count ( $allCrops ); $i ++) {
																	$units = getUnitsByCropname ( $allCrops [$i] ['cropname'] );
																	for($j = 0; $j < count ( $units ); $j ++) {
																		if ($units [$j] != null) {
																			echo "<option value='";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo " '>";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo "</option>";
																		}
																	}
																}
																?>
	              						</select></td>
		<td colspan="2" align="center"><input name="cropNum3"
			value="
<?php
if (isset ( $_GET ['cropNum3'] )) {
	echo $_GET ['cropNum3'];
} else {
	echo 0;
}
?>" /></td>
		<td colspan="1" align="center"><select name="customer3" id="customer3">
            								<?php
																				
																				if (isset ( $_GET ['customer3'] )) {
																					echo "<option value='";
																					echo $_GET ['customer3'];
																					echo " '>";
																					echo $_GET ['customer3'];
																					echo "</option>";
																				}
																				$allCustomers = getDonationCustomers ();
																				for($i = 0; $i < count ( $allCustomers ); $i ++) {
																					echo "<option value=\"" . $allCustomers [$i] ['customername'] . "\">" . $allCustomers [$i] ['customername'] . "</option>";
																				}
																				?>
	              						</select></td>
	</tr>
	<tr>
		<td colspan="2" scope="row" align="center"><select
			name="cropNameWithUnit4" id="cropNameWithUnit4">
        								<?php
																if (isset ( $_GET ['cropNameWithUnit4'] )) {
																	echo "<option value='";
																	echo $_GET ['cropNameWithUnit4'];
																	echo " '>";
																	echo $_GET ['cropNameWithUnit4'];
																	echo "</option>";
																}
																$allCrops = getAllCrops ();
																for($i = 0; $i < count ( $allCrops ); $i ++) {
																	$units = getUnitsByCropname ( $allCrops [$i] ['cropname'] );
																	for($j = 0; $j < count ( $units ); $j ++) {
																		if ($units [$j] != null) {
																			echo "<option value='";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo " '>";
																			echo $allCrops [$i] ['cropname'];
																			echo " - ";
																			echo $units [$j];
																			echo "</option>";
																		}
																	}
																}
																?>
	              						</select></td>
		<td colspan="2" align="center"><input name="cropNum4"
			value="<?php
			if (isset ( $_GET ['cropNum4'] )) {
				echo $_GET ['cropNum4'];
			} else {
				echo 0;
			}
			?>" /></td>
		<td colspan="1" align="center"><select name="customer4" id="customer4">
            								<?php
																				if (isset ( $_GET ['customer4'] )) {
																					echo "<option value='";
																					echo $_GET ['customer4'];
																					echo " '>";
																					echo $_GET ['customer4'];
																					echo "</option>";
																				}
																				$allCustomers = getDonationCustomers ();
																				for($i = 0; $i < count ( $allCustomers ); $i ++) {
																					echo "<option value=\"" . $allCustomers [$i] ['customername'] . "\">" . $allCustomers [$i] ['customername'] . "</option>";
																				}
																				?>
	              						</select></td>
	</tr>
	<tr>
		<th colspan="5" scope="row" align="center"><input type="submit"
			name="submitOutput" value="submit!" /></th>
	</tr>
</table>
</form>
</div>
</div>
</div>
<div style="clear: both;">&nbsp;</div>

<div id="footer">
<p>Copyright (c) 2010 Dilmun Hill Team.</p>
</div>

</body>

</html>